package filter;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.File;

public class HandlerGetInfo extends Handler {

	HandlerGetInfo(Filter filter){
		super(filter);
	}
	
	@Override
	public void doCmd(String path) throws Exception{
		if(!(path.split(" ").length == 1)) {
			this.cmdError();
			throw new IOException(ErrorMessage);
		}
		
		if(new File(path).exists()) {
			for(String info : filtOperation.getFileInfo(path)) {
				System.out.println(info);
			}
		} else {
			this.fileError();
			throw new FileNotFoundException(ErrorMessage);
		}
	}

	@Override
	public void doTips() {
		System.out.println("Format : -info [path]	\n"
				+ "	For show all the information of the file");
	}
}
